<?php

namespace App\Http\Requests\Backend;

use Illuminate\Foundation\Http\FormRequest;

class SiteRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch($this->method()) {
            /*
             * login
             */
            case 'POST': {
                return [
                    'account' => 'required',
                    'password' => 'required',
                ];
            }
            /*
             * logout
             */
            case 'GET': {
                return [];
            }
            default: {
                return [];
            }
        }
    }

    /**
     * 验证信息返回
     *
     * @return array
     */
    public function messages()
    {
        return [
            'account.required' => '请填写账号',
            'password.required' => '请填写密码',
        ];
    }
}